function Header(){
  this.oHead=$("#head")
  this.oIfuser=this.oHead.find(".iconfont_user")
  this.oUimg=this.oHead.find(".user_img")
  this.oUcart=this.oHead.find(".user_cart")
  this.ologinItem=this.oHead.find(".login_item")
  
  
  this.tellnumber=localStorage.getItem('ACTIVE_USER')
  
  this.headerChange()
  this.headerEvent()
  }
  
  
  Header.prototype.headerChange = function () { 
     if(this.tellnumber){
      cart({
        tellnumber: this.tellnumber,
      }).then(res => {
        if(res.status){
          console.log(res.data.length);
          $(".cart_icon_num").html(res.data.length)  
        }     
      })
       console.log(123);
       this.oIfuser.css("display","none")
      this.oUimg.css("display","block")
      this.ologinItem.css("display","block")
      $(".cart_out_tip").css("display","none")
      $(".cart_icon_tip").css("display","block")
     }else{
      this.oIfuser.css("display","block")
      this.oUimg.css("display","none")
      this.ologinItem.css("display","none")
      $(".cart_out_tip").css("display","block")
      $(".cart_icon_tip").css("display","none")
     }
  }

  Header.prototype.headerEvent = function (){
    this.oHead.click((e)=>{
     let target=e.target
     if(target.classList.contains("out")){
       console.log(123);
      localStorage.removeItem('ACTIVE_USER')
      location.href = "./littleDuck.html"
      // this.headerChange()
     }
  
     if(target.classList.contains("cart_icon")){
      if(this.tellnumber){
        location.href = "./cart.html"
      }else{
        location.href = "./login.html"
      }
     }
  
     if(target.classList.contains("user_icon")){
      if(this.tellnumber){
        // location.href = "./cart.html"
      }else{
        location.href = "./login.html"
      }
     }

     if(target.classList.contains("user_set")){
      if(this.tellnumber){
        location.href = "./user.html"
      }else{
        location.href = "./login.html"
      }
     }
  
     if(target.classList.contains("icon-sousuoxiao")){
      console.log(2);
      const kw=$(target).prev().val()
      console.log(kw);
      location.href = `./littleDuck_list.html?kw=${kw}`
    }
  
    })
  }

  new Header()